package scalab.filters.selectors

import scalab.core.dependencies.{Dependency, HardDependency}

/**
* Selects specified files.
*/

trait Files extends scalab.core.component.Selector{

	Files.cnt += 1

	override val name: String = "Files$" + Files.cnt

	override def select(d: Dependency): Boolean = 
		staticDependencies exists {s => s sameResource d}
	
	
}

object Files{

	import java.io.File
	import scalab.utils.Path

	private var cnt = 0

	def apply(path: String): Files = new Files{
		override val staticDependencies = List(HardDependency(Path(path)))
	}

	def apply(paths: Iterable[String]): Files = new Files{
		override val staticDependencies = paths map {p => HardDependency(Path(p))}
	}

	def apply(baseDir: String, paths: Iterable[String]): Files = apply(paths map {p => Path(baseDir) + p})

	def apply(baseDir: String,  paths: String*): Files = apply(baseDir, paths)

	def apply(file: File): Files = apply(file.getCanonicalPath)
}
